/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package models;

import static controllers.Application.show;
import java.util.*;
import javax.persistence.*;
import play.data.validation.MaxSize;
import play.data.validation.Required;
import play.db.jpa.*;

/**
 *
 * @author eruiz
 */
@Entity

public class Comment extends Model {

    @Required
    public String author;

    @Required
    public Date postedAt;

    @Lob
    @Required
    @MaxSize(10000)
    public String content;

    @ManyToOne
    @Required
    public Post post;

    public Comment(String author, String content, Post post) {
        this.author = author;
        this.postedAt = new Date();
        this.content = content;
        this.post = post;
    }

    public String toString() {
        return content.substring(0, 10)+ "...";
    }

}
